/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
char** summaryRanges(int* nums, int numsSize, int* returnSize) {
    int n = numsSize;
    char** res = (char**)malloc(sizeof(char*) * n);
    int j = 0;
    int count = 0;
    for (int i = 0; i < n; i++) {
        // 将 nums[i + 1] - nums[i] != 1 改成 nums[i + 1] != nums[i] + 1
        // 目的是：防止整数溢出
        if (i == n - 1 || nums[i + 1] != nums[i] + 1) {
            char* str = (char*)malloc(sizeof(char) * 30);
            if (j != i) {
                sprintf(str, "%d->%d", nums[j], nums[i]);
            } else {
                sprintf(str, "%d", nums[j]);
            }
            res[count++] = str;
            j = i + 1;
        }
    }
    *returnSize = count;
    return res;
}